|
|
|
|
|
|
|
Programming Applications for Windows |
|
|
|
|
|
|
|
|
Many programmers are coming from DOS-based systems or mainframe/minicomputer systems and are now having to learn how to program for Windows. There are several key differences in the way you code for DOS/mainframes versus how you code for Windows. The main difference you must overcome involves the concept of event-driven versus procedural programming. |
|
|
|
|
|
|
|
|
In procedural programs, the program begins and starts telling the operating system what to do (for example, display a line on the screen or get a keystroke from the user). The program is in control and gives directives to the operating system. The user cannot do anything that the program does not allow. The user must follow the programs flow and cannot deviate from that flow. |
|
|
|
|
|
|
|
|
In addition, a procedural system usually only allows a single task to be executing at any one time. Therefore, to execute another program one must exit the current program and then start another one. For example, if youre using a word processor in this environment and want to now run a spreadsheet, you need to leave your word processor prior to starting the spreadsheet application. |
|
|
|
|
|
|
|
|
In an event-driven application, the operating system is in control. Instead of the program telling the operating system what to do, the operating system tells the program whats going on and gives it a chance to respond. It does this through the mechanism of an event. |
|
|
|
 |
|
|
|
|
TIP The operating system is in control in an event-driven system. |
|
|
|
|
|
|
|
|
Windows is a multitasking operating system. This means that more than one program can be running concurrently. This allows the user to switch from one program to another at any time. You, as an application programmer, will need to think differently about how you write your programs. Instead of writing code to control everything about the environment, such as the keyboard input and waiting for keystrokes, youll now simply respond to an event that the operating system gives to you. You can no longer force the operating system to stop and wait for your program to complete; you need to be aware that the operating system will give your program a time-slice to run within. This is what is meant by multitasking. |
|
|
|
|
|